home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-12-23 | 3.1 KB | 124 lines | [TEXT/ToyS] |
- --
- -- release history:
- -- 1.0 (941223) original release
- --
- -- Known bugs and limitations:
- -- • Windows may end up (partly) outside the screen limits
- -- • Error detection and handling is poor
- --
- property topFolderXPosition : 0
- property topFolderYPosition : 0
-
- on processTopFolder(theFolder)
- tell application "Finder"
- activate
- open theFolder
- set thePosition to position of window of theFolder
- end tell
- set topFolderXPosition to item 1 of thePosition
- set topFolderYPosition to item 2 of thePosition
- processFolder(theFolder, 0)
- end processTopFolder
-
- on processFolder(theFolder, depth)
- tell application "Finder"
- activate
- open theFolder
- try
- my moveFolder(theFolder, depth)
- my sizeFolder(theFolder, depth)
- on error m
- -- just ignore errors. Thus, one can drop a disk which contains some folders to
- -- which one does not have access
- end try
- set theSubFolders to (folders in theFolder)
- repeat with subFolder in theSubFolders
- my processFolder(subFolder, depth + 1)
- end repeat
- close theFolder
- end tell
- end processFolder
-
- on moveFolder(theFolder, depth)
- -- Configure here for your preferences (and screen size)
- set xpos to 18 * depth + topFolderXPosition
- set ypos to 18 * depth + topFolderYPosition
- if xpos > 400 then set xpos to 400
- if ypos > 300 then set ypos to 300
- tell application "Finder"
- set position of window of theFolder to {xpos, ypos}
- end tell
- end moveFolder
-
- on sizeFolder(theFolder, depth)
- tell application "Finder"
- set numItems to count items of theFolder
- -- configure here
- if numItems < 9 then
- tell window of theFolder
- set view to icon
- if numItems < 5 then
- set size to {400, 100} -- one row
- else
- set size to {400, 200} -- two rows
- end if
- clean up by name
- set zoomed to true
- end tell
- else if numItems < 25 then
- tell window of theFolder
- set view to small icon
- set size to {250, 275}
- clean up by name
- set zoomed to true
- end tell
- else
- tell window of theFolder
- set size to {450, 250} -- wide to make date readable
- --
- -- Clean up icons in case we switch back later. Don't do icon view. That
- -- would slow down an already slow program and with this many items
- -- chances are 'by Icon' will never be selected.
- --
- set view to small icon
- clean up by name
- set view to name
- reveal first item -- to scroll back to {0,0}
- end tell
- end if
- end tell
- end sizeFolder
-
- on run
- set theFolder to choose folder with prompt "Select folder to clean up:"
- if theFolder ≠ "" then
- tell application "Finder"
- my processTopFolder(folder theFolder)
- end tell
- end if
- end run
-
- on open theFiles
- set allAreFolders to true
- repeat with theFile in theFiles
- if last character of (theFile as string) is not ":" then
- set allAreFolders to false
- exit repeat
- end if
- end repeat
- if allAreFolders then
- tell application "Finder"
- repeat with theFile in theFiles
- set theFolder to folder theFile
- try
- my processTopFolder(theFolder)
- on error message
- display dialog message buttons "Ok"
- end try
- end repeat
- end tell
- else
- display dialog "Drop only folders on this droplet, please!" buttons "Ok"
- end if
- end open
-